package com.xiaobaibai.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import com.xiaobaibai.valid.AddGroup;
import com.xiaobaibai.valid.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author xiaobaibai
 * @since 2020-10-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("category")
@ApiModel(value="Category对象", description="")
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class Category implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableField(exist = false)
//    @JsonProperty(value = "children")
    private List<Category> childList;

    @ApiModelProperty(value = "分类id")
    @TableId(value = "id", type = IdType.AUTO)
    @Null(message = "新增不可指定id",groups = AddGroup.class)
    @NotNull(message = "修改需指定id",groups = UpdateGroup.class)
//    @JsonProperty(value = "value")
//    @JsonAlias(value = "id")
    private Integer id;

    @ApiModelProperty(value = "分类名称")
    @TableField("category_name")
    @NotNull(message = "分类名称不可为空",groups = AddGroup.class)
//    @JsonProperty(value = "label")
//    @JsonAlias(value = "categoryName")//可接收
    private String categoryName;

    @ApiModelProperty(value = "分类父id")
    @TableField("category_p_id")
    @NotNull(message = "父分类id不可为空",groups = AddGroup.class)
    private Integer categoryPId;

    @ApiModelProperty(value = "分类图片")
    @TableField("category_image")
    @NotNull(message = "分类图片不可为空",groups = AddGroup.class)
    private String categoryImage;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;


}
